package com.example.sql;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class MyOpenHelper extends SQLiteOpenHelper {

    public MyOpenHelper(Context context) {
        super(context, "yuanmenglong.db", null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        sqLiteDatabase.execSQL("create table info (_id integer primary key autoincrement,username varchar(10) not null,pass varchar(10) not null)");
        Log.e( "onCreate: ", String.valueOf(sqLiteDatabase));
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
        //添加数据
        sqLiteDatabase.execSQL("insert into info (username , pass) values ('tom','123456')");
        sqLiteDatabase.execSQL("insert into info (username , pass) values ('jack','123456')");
    }
}
